package com.sangcomz.fishbun.ui.album.model.repository;

import com.sangcomz.fishbun.adapter.image.ImageAdapter;
import com.sangcomz.fishbun.datasource.CameraDataSource;
import com.sangcomz.fishbun.datasource.FishBunDataSource;
import com.sangcomz.fishbun.datasource.ImageDataSource;
import com.sangcomz.fishbun.ui.album.model.Album;
import com.sangcomz.fishbun.ui.album.model.AlbumMenuViewData;
import com.sangcomz.fishbun.ui.album.model.AlbumMetaData;
import com.sangcomz.fishbun.ui.album.model.AlbumViewData;
import com.sangcomz.fishbun.util.future.CallableFutureTask;
import ohos.utils.net.Uri;

import java.util.List;

public class AlbumRepositoryImpl implements AlbumRepository {

    private ImageDataSource imageDataSource;
    private FishBunDataSource fishBunDataSource;
    private CameraDataSource cameraDataSource;
    private AlbumViewData viewData = null;

    public AlbumRepositoryImpl(ImageDataSource imageDataSource, FishBunDataSource fishBunDataSource, CameraDataSource cameraDataSource) {
        this.imageDataSource = imageDataSource;
        this.fishBunDataSource = fishBunDataSource;
        this.cameraDataSource = cameraDataSource;
    }

    @Override
    public CallableFutureTask<List<Album>> getAlbumList() {
        return imageDataSource.getAlbumList(
                fishBunDataSource.getAllViewTitle(),
                fishBunDataSource.getExceptMimeTypeList(),
                fishBunDataSource.getSpecifyFolderList());
    }

    @Override
    public CallableFutureTask<AlbumMetaData> getAlbumMetaData(Long albumId) {
        return imageDataSource.getAlbumMetaData(
                albumId,
                fishBunDataSource.getExceptMimeTypeList(),
                fishBunDataSource.getSpecifyFolderList());
    }

    @Override
    public AlbumViewData getAlbumViewData() {
        if (viewData == null) {
            viewData = fishBunDataSource.getAlbumViewData();
        }

        return viewData;
    }

    @Override
    public ImageAdapter getImageAdapter() {
        return fishBunDataSource.getImageAdapter();
    }

    @Override
    public List<Uri> getSelectedImageList() {
        return fishBunDataSource.getSelectedImageList();
    }

    @Override
    public AlbumMenuViewData getAlbumMenuViewData() {
        return fishBunDataSource.gatAlbumMenuViewData();
    }

    @Override
    public String getMessageNotingSelected() {
        return fishBunDataSource.getMessageNothingSelected();
    }

    @Override
    public int getMinCount() {
        return fishBunDataSource.getMinCount();
    }

    @Override
    public String getDefaultSavePath() {
        return cameraDataSource.getPicturePath();
    }
}